import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 班级作业信息 */
export interface ClassHomework {
          id: number; // 作业唯一ID
          classId: number; // 班级ID
          title: string; // 作业标题
          description: string; // 作业描述
          bookId: number; // 相关绘本ID
          creatorId: number; // 作业创建者ID
          creator: string; // 创建者
          createTime: string | Dayjs; // 创建时间
          updater: string; // 更新者
          updateTime: string | Dayjs; // 更新时间
          deleted: boolean; // 是否删除
          deadline: string | Dayjs; // 作业截止时间
  }

// 班级作业 API
export const ClassHomeworkApi = {
  // 查询班级作业分页
  getClassHomeworkPage: async (params: any) => {
    return await request.get({ url: `/pickbook/class-homework/page`, params })
  },

  // 查询班级作业详情
  getClassHomework: async (id: number) => {
    return await request.get({ url: `/pickbook/class-homework/get?id=` + id })
  },

  // 新增班级作业
  createClassHomework: async (data: ClassHomework) => {
    return await request.post({ url: `/pickbook/class-homework/create`, data })
  },

  // 修改班级作业
  updateClassHomework: async (data: ClassHomework) => {
    return await request.put({ url: `/pickbook/class-homework/update`, data })
  },

  // 删除班级作业
  deleteClassHomework: async (id: number) => {
    return await request.delete({ url: `/pickbook/class-homework/delete?id=` + id })
  },

  /** 批量删除班级作业 */
  deleteClassHomeworkList: async (ids: number[]) => {
    return await request.delete({ url: `/pickbook/class-homework/delete-list?ids=${ids.join(',')}` })
  },

  // 导出班级作业 Excel
  exportClassHomework: async (params) => {
    return await request.download({ url: `/pickbook/class-homework/export-excel`, params })
  }
}